#region Using directives

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Net.Sockets;
using System.Net;
using System.Threading;

#endregion
using System.Diagnostics;
using HTTPMsgAPI;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Ipc;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Lifetime;
using System.IO;
using System.Collections.Specialized;
using timers = System.Timers;
using Thinxoft.HttpLib;

namespace HTTPListProc
{
    public class HandlerPool
    {
        static Dictionary<int, HandlerProxy> handlers = new Dictionary<int, HandlerProxy>();
        static int current = 0;

        public static void AddRequestHandlerProxy(HandlerProxy proxy)
        {
            handlers.Add(proxy.ID, proxy);
        }

        public static HandlerProxy GetNextRequestHandler()
        {
            if (current >= handlers.Count)
                current = 0;

            HandlerProxy proxy = handlers[current];
            current++;
            return proxy;
        }

        public static void Dispose()
        {
            foreach (HandlerProxy proxy in handlers.Values)
            {
                proxy.Dispose();
                //proxy = null;
            }
        }
    }
}
